﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using yncTech.BusinessObjects;

public partial class Admin_Sys_Sec_Sec005 : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void PageChanged(object sender, DataGridPageChangedEventArgs e)
    {

        /*
SELECT  a.LoginName, d.RoleName,b.UserName,b.Manager,b.Email,a.CreatedBy,b.CreatedTime,a.IsActive,e.NAME ThiredUnitName,f.Value1 dept
FROM    dbo.T_S_Users a
        INNER JOIN dbo.T_S_UserInfo b ON a.UserID = b.UserID
        INNER JOIN dbo.T_S_UserRoles c ON a.UserID = c.UserID
        INNER JOIN dbo.T_S_Role d ON c.RoleID = d.RoleID
        INNER JOIN BF_ThirdUnit e ON b.ThirdUnitID = e.ThirdUnitID
        INNER JOIN dbo.T_S_CodeTable f ON b.DeptNo = f.Code
         */

        TSUsersQuery q1 = new TSUsersQuery("q1");
        TSUserInfoQuery q2 = new TSUserInfoQuery("q2");
        TSUserRolesQuery q3 = new TSUserRolesQuery("q3");
        TSRoleQuery q4 = new TSRoleQuery("q4");
        BFThirdUnitQuery q5 = new BFThirdUnitQuery("q5");
        TSCodeTableQuery q6 = new TSCodeTableQuery("q6");
        q1.InnerJoin(q2).On(q1.UserID == q2.UserID)
            .InnerJoin(q3).On(q1.UserID == q3.UserID)
            .InnerJoin(q4).On(q3.RoleID == q4.RoleID)
            .InnerJoin(q5).On(q2.ThirdUnitID == q5.ThirdUnitID)
            .InnerJoin(q6).On(q2.DeptNo == q6.Code);
        q1.Select(q1.LoginName,q4.RoleName,q2.UserName,q1.UserID,q2.Manager,q2.Email,q2.CreatedBy,q2.CreatedTime,q1.IsActive,q5.Name.As("ThirdUnitName"),q6.Value1.As("DeptName"));
            
        

        gridUsers.CurrentPage = e.NewPageIndex;
        gridUsers.DataSource = q1.LoadDataTable();
        gridUsers.DataBind();

    }
}